//
//  BaseNavigationController.swift
//  CandyDate
//
//  Created by zolobdz on 2017/11/3.
//  Copyright © 2017年 HeChao. All rights reserved.
//

import UIKit

class BaseNavigationController: UINavigationController {

    //MARK: Propertys
    
    
    //MARK: LifeCycle
    override func viewDidLoad() {
        super.viewDidLoad()
        navigationBar.isTranslucent = false
    }
    
    
//    func setBarBackgroundToThemeColor() {
//
//        navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
//        navigationBar.setBackgroundImage(gradientImage(), for: .default)
//        navigationBar.tintColor = UIColor.white
//        navigationBar.backIndicatorImage = UIImage(resource: R.image.navi_back_white)?.withRenderingMode(.alwaysOriginal)
//        navigationBar.backIndicatorTransitionMaskImage = UIImage(resource: R.image.navi_back_mask)
//        navigationBar.isTranslucent = false
//    }
    
//    func setBarBackgroundToWhiteColor() {
//        navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.black]
//        navigationBar.tintColor = UIColor.black
//        navigationBar.backIndicatorImage = UIImage(resource: R.image.navi_back)?.withRenderingMode(.alwaysOriginal)
//        navigationBar.backIndicatorTransitionMaskImage = UIImage(resource: R.image.navi_back_mask)
//        navigationBar.setBackgroundImage(CDUtility.createImageWithColor(color: UIColor.white), for: UIBarMetrics.default)
//        navigationBar.isTranslucent = false
//    }
    
//    func gradientImage() -> UIImage {
//        let gradientLayer = CAGradientLayer()
//        gradientLayer.frame = CGRect(x: 0, y: -STATUSHEIGHT, width: DeviceInfo.screenWidth, height: view.frame.height+STATUSHEIGHT)
//        gradientLayer.startPoint = CGPoint(x: 0, y: 0)
//        gradientLayer.endPoint = CGPoint(x: 1, y: 0)
//        gradientLayer.colors = [UIColor(rgba: "#fe5d87").cgColor,UIColor(rgba: "#f629b0").cgColor]
//
//        UIGraphicsBeginImageContext(gradientLayer.bounds.size)
//        gradientLayer.render(in: UIGraphicsGetCurrentContext()!)
//        let image = UIGraphicsGetImageFromCurrentImageContext()
//        UIGraphicsEndImageContext()
//        return image!;
//    }
    
//    override var preferredStatusBarStyle: UIStatusBarStyle{
//        return .lightContent
//    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if self.childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
        }
        let backItem = UIBarButtonItem()
        backItem.title = ""
        viewController.navigationItem.backBarButtonItem = backItem
        super.pushViewController(viewController, animated: animated)
    }
    
}
